package com.ztman.service.tenant.controller;

import com.ztman.basic.annotation.log.SysLog;
import com.ztman.basic.base.R;
import com.ztman.basic.base.controller.SuperCacheController;
import com.ztman.service.tenant.dto.DatasourceConfigPageQuery;
import com.ztman.service.tenant.dto.DatasourceConfigSaveDTO;
import com.ztman.service.tenant.dto.DatasourceConfigUpdateDTO;
import com.ztman.service.tenant.entity.DatasourceConfig;
import com.ztman.service.tenant.service.DatasourceconfigService;
import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@Slf4j
@Validated
@RestController
@RequestMapping("/datasourceConfig")
@Api(value = "Datasource", tags = "数据源")
@SysLog(enabled = false)
public class DatasourceConfigsController  extends SuperCacheController<DatasourceconfigService, Long, DatasourceConfig, DatasourceConfigPageQuery, DatasourceConfigSaveDTO, DatasourceConfigUpdateDTO> {

    @Override
    public R<DatasourceConfig> handlerSave(DatasourceConfigSaveDTO model) {
        DatasourceConfig datasourceConfig = baseService.save(model);
        return success(datasourceConfig);
    }

    @Override
    public R<Boolean> handlerDelete(List<Long> ids) {
        // 这个操作相当的危险，请谨慎操作！！!
        return success(baseService.delete(ids));
    }
}
